#define LOG_TAG "det_task.tag"
#include "det_task.h"
#include "elog.h"

#include "../drivers/adc.h"
#include "device.h"

#include "ins_det.h"
#include "temp_det.h"
#include "cc1_det.h"

rt_adc_device_t adc;

/**
 * @brief CC1的ADC采集
 */
int cc1_det_init(void)
{
    int ret = 0;
    adc = (rt_adc_device_t)rt_device_find("adc1");
    if (adc != RT_NULL)
    {
        log_d("adc device find success.");
    }
    return ret;
}
INIT_APP_EXPORT(cc1_det_init);

osThreadId_t detTaskHandle;
const osThreadAttr_t detTask_attributes = {
    .name = "detTask",
    .stack_size = 1024 + 512,
    .priority = (osPriority_t)osPriorityRealtime,
};

/**
 * @brief                   检测任务
 * @param  params           Function Param doc
 */
void det_task(void *params)
{
    for (;;)
    {
        cc1_det();
        insulation_detection_fsm();
        ntc_temp_poll(TEMP_CH1);
        ntc_temp_poll(TEMP_CH2);
        osDelay(5);
    }
}



